From 24e5195db4dbbf07ce9174e7ab030f33923f7849 Mon Sep 17 00:00:00 2001 From: Stevan Earl Date: Tue, 11 Aug 2026 15:34:31 -0700 Subject: [PATCH] schema: reserve NONE for WATCHES AnimIDs --- db/include/tablemacros.m4 | 8 ++++++-- db/schemas/sokwedb/tables/create/watches.m4 | 4 +++- doc/src/tables/watches.m4 | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/db/include/tablemacros.m4 b/db/include/tablemacros.m4 index 43032ec..ef1d17d 100644 --- a/db/include/tablemacros.m4 +++ b/db/include/tablemacros.m4 @@ -120,10 +120,14 @@ dnl colname The name of the column in lower case. dnl Colname The name of the column in camelcaps. dnl null Either `NULL' or `NOT NULL'. dnl -define(`animid_type_column', ` +changequote([,]) +define([animid_type_column], [ $1 TEXT $3 CONSTRAINT "$2 must be a BIOGRAPHY_DATA.AnimID value" - REFERENCES biography_data(animid)')dnl + REFERENCES biography_data(animid) + CONSTRAINT "$2 must be an individual, sdb_no_focal is not allowed" + CHECK ($1 <> 'sdb_no_focal')])dnl +changequote(`,') dnl An AnimID column that does not have to reference BIOGRAPHY_DATA.AnimID. changequote([,]) diff --git a/db/schemas/sokwedb/tables/create/watches.m4 b/db/schemas/sokwedb/tables/create/watches.m4 index e8a3761..8171b87 100644 --- a/db/schemas/sokwedb/tables/create/watches.m4 +++ b/db/schemas/sokwedb/tables/create/watches.m4 @@ -42,7 +42,9 @@ changequote(`,') CREATE TABLE watches ( key_column(`WATCHES', `WID', INTEGER) - ,animid_type_column(`animid', `AnimID', `NOT NULL') + ,animid TEXT NOT NULL + CONSTRAINT "AnimID must be a BIOGRAPHY_DATA.AnimID value" + REFERENCES biography_data(animid) ,commid TEXT NOT NULL REFERENCES comm_ids ,date DATE NOT NULL diff --git a/doc/src/tables/watches.m4 b/doc/src/tables/watches.m4 index f186365..a02bd92 100644 --- a/doc/src/tables/watches.m4 +++ b/doc/src/tables/watches.m4 @@ -263,13 +263,16 @@ AnimID (focal or other watched ANIMal ID) .. |WATCHES.AnimID_summary| replace:: The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| identifying the - individual under observation. + individual under observation, or ``sdb_no_focal`` when no individual + is associated with the watch. |WATCHES.AnimID_summary| The designated individual that is the focal of a follow, or the -individual observed at the feeding station, or ``sdb_unk`` -- the -unknown individual --, etc., depending on the |WATCHES.Type| value. +individual observed at the feeding station, or ``sdb_unk`` when such an +individual exists but is unidentified, etc., depending on the +|WATCHES.Type| value. The ``sdb_no_focal`` value has a different meaning: +there is no focal or other watch-associated individual. |notnull| -- 2.34.1